<template>
  <div class="homepage">
    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="200">
        <el-menu
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          :collapse="isCollapse"
          :router="true"
        >
          <qf-sub-menu :sideMenu="menuList"></qf-sub-menu>
        </el-menu>
      </el-aside>
      <el-container>
        <!-- 顶部栏 -->
        <el-header>
          <el-row type="flex" class="row-bg" justify="space-between">
            <el-col :span="6"
              ><div class="grid-content bg-purple">
                <i
                  class="iconfont icon-zuoshouqi"
                  @click="isCollapse = !isCollapse"
                ></i>
              </div>
            </el-col>
            <el-col :span="6"
              ><div class="grid-content bg-purple-light">
                千锋管理系统
              </div></el-col
            >
            <el-col :span="6"
              ><div class="grid-content bg-purple">
                <el-avatar
                  :size="40"
                  src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605717374049&di=f7c790a47a628eedf97bd81a12cb4f0e&imgtype=0&src=http%3A%2F%2Fww1.sinaimg.cn%2Fmw690%2F5301ff11ly1gb58jwjhikj20p00p0q4l.jpg"
                ></el-avatar>
                欢迎您：
                <b>{{ userInfo.nickname }}</b>
                <span class="quit" @click="quit">退出</span>
              </div>
            </el-col>
          </el-row>
        </el-header>
        <!-- 主体 -->
        <el-main>
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item :to="{path:item.path}" v-for="item in crumbs" :key="item.name">{{item.meta.name}}</el-breadcrumb-item>
          </el-breadcrumb>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style>
/* 顶部栏style */
.quit {
  color: red;
}
.el-row {
  margin-bottom: 20px;
  /* &:last-child {
      margin-bottom: 0;
    } */
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: pink;
}
.bg-purple {
  background: pink;
}

.bg-purple-light {
  background: pink;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: pink;
  padding: 0;
  height: 60px;
}
.el-avatar {
  vertical-align: middle;
}
/* 侧边导航style */
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-header,
.el-footer {
  background-color: pink;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>

<script>
//import { getLoginLog } from "@/api";
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState(["userInfo", "menuList","crumbs"]),
  },
  mounted() {
    // getLoginLog().then((res) => {
    //   //除了登录和注册不需要携带token,所以获取日志也需要携带token
    //   console.log(res);
    // });
  },
  data() {
    return {
      isCollapse: false, //是否水平折叠收起菜单栏
    };
  },
  methods: {
    quit() {
      //1.清除token和userInfo
      //2.跳转到登录页面
      localStorage.removeItem("login-userInfo");
      localStorage.removeItem("login-tokin");
      this.$router.push("/login");
      //刷新页面
      window.location.reload();
    },
  },
};
</script>